var pageObj = { currentPage: 1, pageSize: 10 };
export default {
  getExper() {
    let searchItem = [
      {
        label: '实验名称',
        prop: 'expName',
        input: true,
      },
      {
        label: '实验模型',
        prop: 'verifyGroup',
        tag: true,
        list: [],
      },
      {
        label: '实验类型',
        prop: 'expGroup',
        tag: true,
        list: [],
      },
      {
        label: '创建时间',
        prop: 'time',
        timeSelect: true,
        type: 'datetimerange',
      },
    ];
    let buttonAll = {
      searchList: [
        {
          type: 'search',
          text: '查询',
          icon: 'el-icon-search',
          alwaysShow: true,
          types: 'primary',
        },
        {
          type: 'clear',
          text: '重置',
          icon: 'el-icon-delete',
          alwaysShow: true,
        },
      ],
    };
    let searchObj = {};
    searchItem.map(it => {
      it.width = '100px';
      searchObj[it.prop] = '';
    });
    let titleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true,
      },
      {
        label: '数据名称',
        prop: 'name',
        width: 120,
      },
      {
        label: '每套拓扑图中使用的数量',
        prop: 'expGroup',
        width: 200,
      },
      {
        label: '总数量',
        prop: 'count',
        width: 120,
      },
      {
        label: '操作',
        prop: 'operate',
        slot: true,
      },
    ];
    let resultItem = [
      {
        label: '名称',
        prop: 'result',
        input: true,
      },
      {
        label: '成果类型',
        prop: 'resultType',
        tag: true,
        list: [{ label: '模型', id: 1 }, { label: '算法', id: 2 }],
      },
      {
        label: '权限',
        prop: 'jurisdiction',
        tag: true,
        list: [{ label: '公开', id: 1 }, { label: '私有', id: 2 }],
      },
      {
        label: '实验描述',
        prop: 'remark',
        inputMore: true,
      },
      {
        label: '成果附件',
        prop: 'resultFile',
        nameProp: 'fileName',
        upload: true,
      },
    ];
    let resultObj = {};
    resultItem.map(it => {
      it.width = '100px';
      resultObj[it.prop] = '';
    });
    let searchData = { ...searchObj, ...pageObj, state: '' };
    let resultData = resultObj;
    return {
      searchItem,
      searchData,
      buttonAll,
      titleList,
      resultItem,
      resultData,
    };
  },
  getFirstForm() {
    let searchItem = [
      {
        label: '实验名称',
        prop: 'expName',
        input: true,
        rules: [{ required: true, message: '请输入实验名称', trigger: 'blur' }],
      },
      {
        label: '实验模型',
        prop: 'verifyGroup',
        tag: true,
        list: [],
        rules: [{ required: true, message: '请选择实验模型', trigger: 'blur' }],
      },
      {
        label: '实验类型',
        prop: 'expGroup',
        tag: true,
        list: [],
      },
      {
        label: '实验期限',
        prop: 'time',
        timeSelect: true,
        type: 'datetimerange',
      },
      {
        label: '申请拓扑资源套数',
        prop: 'tpCount',
        inputNum: true,
      },
      {
        label: '结果提交方式',
        prop: 'resSubway',
        tag: true,
        list: [],
      },
      {
        label: '实验描述',
        prop: 'remark',
        inputMore: true,
      },
    ];
    let searchObj = {};
    searchItem.map(it => {
      searchObj[it.prop] = '';
    });
    let searchData = { ...searchObj, expGroups: '' };
    return {
      searchItem,
      searchData,
    };
  },
  getResource() {
    let searchItem = [
      {
        label: '名称',
        prop: 'name',
        input: true,
      },
      /* {
        label: "类型",
        prop: "type",
        tag: true,
        list: [],
      }, */
      {
        label: '属性',
        prop: 'attribute',
        tag: true,
        list: [
          {
            label: '可复制',
            id: '1',
          },
          {
            label: '不可复制',
            id: '2',
          },
        ],
      },
      {
        label: '创建时间',
        prop: 'createTime',
        timeSelect: true,
        type: 'datetime',
      },
      {
        label: '关键字',
        prop: 'remark',
        input: true,
      },
    ];
    let buttonAll = {
      searchList: [
        {
          type: 'search',
          text: '查询',
          icon: 'el-icon-search',
          alwaysShow: true,
          types: 'primary',
        },
        {
          type: 'clear',
          text: '重置',
          icon: 'el-icon-delete',
          alwaysShow: true,
        },
      ],
    };
    let titleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true,
      },
      {
        label: '数据名称',
        prop: 'name',
      },
      {
        label: '数据类型',
        prop: 'type',
      },
      {
        label: '描述',
        prop: 'remark',
      },
      {
        label: '属性',
        prop: 'attribute',
        getData: row => {
          if (row.attribute) {
            if (row.attribute === '1') {
              return '可复制';
            } else if (row.attribute === '2') {
              return '不可复制';
            }
          }
        },
      },
      // {
      //   label: '余量/总量',
      //   prop: 'total',
      //   getData: row => {
      //     if (row.unusedCount && row.totalCount) {
      //       return row.unusedCount + '/' + row.totalCount;
      //     }
      //   },
      // },
      // {
      //   label: '阈值',
      //   prop: 'thresholdValue',
      // },
      {
        label: '创建时间',
        prop: 'createTime',
      },
      {
        label: '操作',
        prop: 'count',
        slot: true,
      },
    ];
    let tableData = [];
    let hardTitleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true,
      },
      {
        label: '硬件名称',
        prop: 'name',
      },
      {
        label: '硬件资源',
        prop: 'hardwareType',
      },
      {
        label: '规格',
        prop: 'specification',
      },
      {
        label: '余量/总量',
        prop: 'total',
        slot: true,
        getData: row => {
          if (row.unusedCount && row.totalCount) {
            return row.unusedCount + '/' + row.totalCount;
          }
        },
      },
      {
        label: '创建时间',
        prop: 'createTime',
      },
      {
        label: '操作',
        prop: 'count',
        slot: true,
      },
    ];
    let moduleTitleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true,
      },
      {
        label: '模型名称',
        prop: 'name',
      },
      {
        label: '模型类型',
        prop: 'type',
      },
      {
        label: '规格',
        prop: 'specification',
      },
      // {
      //   label: '余量/总量',
      //   prop: 'total',
      //   slot: true,
      //   getData: row => {
      //     if (row.unusedCount && row.totalCount) {
      //       return row.unusedCount + '/' + row.totalCount;
      //     }
      //   },
      // },
      {
        label: '创建时间',
        prop: 'createTime',
      },
      {
        label: '操作',
        prop: 'count',
        slot: true,
      },
    ];
    let toolTitleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true,
      },
      {
        label: '工具名称',
        prop: 'name',
      },
      {
        label: '工具类型',
        prop: 'type',
      },
      {
        label: '规格',
        prop: 'specification',
      },
      // {
      //   label: '余量/总量',
      //   prop: 'total',
      //   slot: true,
      //   getData: row => {
      //     if (row.unusedCount && row.totalCount) {
      //       return row.unusedCount + '/' + row.totalCount;
      //     }
      //   },
      // },
      {
        label: '创建时间',
        prop: 'createTime',
      },
      {
        label: '操作',
        prop: 'count',
        slot: true,
      },
    ];
    let choseTitleList = [
      {
        label: '序号',
        prop: 'index',
        slot: true,
      },
      {
        label: '名称',
        prop: 'name',
      },
      {
        label: '每套拓扑图中使用的数量',
        prop: 'count',
      },
      // {
      //   label: '余量/总量',
      //   prop: 'total',
      //   getData: row => {
      //     if (row.unusedCount && row.totalCount) {
      //       return row.unusedCount + '/' + row.totalCount;
      //     }
      //   },
      // },
      // {
      //   label: '阈值',
      //   prop: 'thresholdValue',
      // },
      {
        label: '总数量',
        prop: 'totalCount',
      },
    ];
    let searchObj = {};
    searchItem.map(it => {
      it.width = it.label.length == 2 ? '60px' : '100px';
      searchObj[it.prop] = '';
    });
    let searchData = { ...searchObj, size: 10, current: 1 };
    return {
      searchItem,
      searchData,
      buttonAll,
      titleList,
      tableData,
      moduleTitleList,
      hardTitleList,
      toolTitleList,
      choseTitleList,
    };
  },
  getExperAudit() {
    let searchItem = [
      {
        label: '实验名称',
        prop: 'expName',
        input: true,
      },
      {
        label: '实验模型',
        prop: 'verifyGroup',
        tag: true,
        list: [],
      },
      {
        label: '实验类型',
        prop: 'expGroup',
        tag: true,
        list: [],
      },
      {
        label: '审核状态',
        prop: 'checkState',
        tag: true,
        list: [{ label: '待审批', id: 1 }, { label: '通过', id: 2 }, { label: '驳回', id: 3 }],
      },
      {
        label: '申请人',
        prop: 'person',
        input: true,
      },
    ];
    let buttonAll = {
      searchList: [
        {
          type: 'search',
          text: '查询',
          icon: 'el-icon-search',
          alwaysShow: true,
          types: 'primary',
        },
        {
          type: 'clear',
          text: '重置',
          icon: 'el-icon-set-up',
          alwaysShow: true,
        },
        {
          type: 'delete',
          text: '批量通过',
          icon: 'el-icon-document-checked',
          alwaysShow: true,
          types: 'primary',
        },
        {
          type: 'import',
          text: '批量驳回',
          icon: 'el-icon-document-delete',
          alwaysShow: true,
          types: 'danger',
        },
      ],
    };
    let titleList = [
      {
        label: '序号',
        prop: 'index',
        // width:100,
        slot: true,
      },
      {
        label: '实验名称',
        prop: 'expName',
        // width: 200,
      },
      {
        label: '实验模型',
        prop: 'verifyGroup',
        // width: 200,
        slot: true,
      },
      {
        label: '实验类型',
        prop: 'expGroups',
        // width: 200,
        // slot: true,
      },
      {
        label: '实验期限',
        prop: 'range',
        // width: 300,
        getData: row => {
          if (row.startTime && row.endTime) {
            return row.startTime + '至' + row.endTime;
          }
        },
      },
      {
        label: '申请人',
        prop: 'person',
        // width: 140,
        sort: true,
      },
      {
        label: '实验状态',
        prop: 'state',
        // width: 200,
        slot: true,
      },
      {
        label: '审核状态',
        prop: 'checkState',
        slot: true,
      },
      {
        label: '催批次数',
        prop: 'urge',
        // width: 150,
        slot: true,
      },
      {
        label: '操作',
        prop: 'operate',
        // width: 200,
        slot: true,
      },
    ];
    let tableData = [];

    // 模型资源
    let modelResList = [
      {
        label: '编号',
        prop: 'index',
        width: 100,
        slot: true,
      },
      {
        label: '实验名称',
        prop: 'expName',
        width: 200,
      },
      {
        label: '属性',
        prop: 'expGroup',
        width: 200,
      },
      {
        label: '描述',
        prop: 'expDes',
        width: 200,
      },
      {
        label: '每套申请数量',
        prop: 'everyNum',
        width: 200,
      },
      {
        label: '申请总数',
        prop: 'totalNum',
        width: 200,
      },
      {
        label: '资源余量',
        prop: 'remainNum',
        width: 200,
      },
      {
        label: '阈值',
        prop: 'threshold',
        slot: true,
      },
    ];
    let searchObj = {};

    searchItem.map(it => {
      it.width = it.label.length == 2 ? '60px' : '100px';
      searchObj[it.prop] = '';
    });

    let searchData = { ...searchObj };

    function unique(arr) {
      return Array.from(new Set(arr));
    }

    return {
      searchItem,
      searchData,
      buttonAll,
      titleList,
      tableData,
      unique,
      modelResList,
    };
  },
};
